package org.aeon.entity.dto;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;

/**
 * @author: MissingAeon
 * @date: 2024/1/26 9:52
 * @description:
 */
@Data
@NoArgsConstructor
public class UserDto implements Serializable {
    @Serial
    private static final long serialVersionUID = 2579704091566891768L;
    private Long id;
    private String username;
    private String nickname;
    private boolean leave;

    public UserDto(Long id) {
        this.id = id;
    }

    public UserDto(String nickname) {
        this.nickname = nickname;
    }

    public UserDto setId(Long id) {
        this.id = id;
        return this;
    }

    public UserDto setUsername(String username) {
        this.username = username;
        return this;
    }

    public UserDto setNickname(String nickname) {
        this.nickname = nickname;
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserDto aUserDto = (UserDto) o;
        if (id != null && id.equals(aUserDto.id)) return true;
        return username != null && username.equals(aUserDto.username);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
